import request from '@/config/axios'

// 楼盘/公寓 VO
export interface ApartmentVO {
  id: number // 主键
  nameZhCn: string // 房屋中文名
  nameEnUs: string // 房屋英文名
  showImages: string // 房屋图片（多个逗号分隔）
  showVideos: string // 房屋视频（多个逗号分隔）
  mainHouseType: string // 主力户型
  priceMin: number // 最小价格（单位：元）
  priceMax: number // 最大价格（单位：元）
  tagsZhCn: string // 中文标签（多个逗号分隔）
  tagsEnUs: string // 英文标签（多个逗号分隔）
  projectType: number // 项目类型（0公寓 1新房 2二手）
  projectProgressZhCn: string // 项目进度（中文）
  projectProgressEnUs: string // 项目进度（英文）
  completionTime: Date // 完工时间
  builderZhCn: string // 建筑商中文名
  builderEnUs: string // 建筑商英文名
  designerZhCn: string // 设计师中文名
  designerEnUs: string // 设计师英文名
  contentZhCn: string // 内容中文详情
  contentEnUs: string // 内容英文详情
  provinceId: number // 所属省份ID
  cityId: number // 所属市ID
  countyId: number // 所属区县ID
  point: string // 坐标点（经纬度逗号分隔）
  pointDetail: string // 定位详情
}

// 楼盘/公寓 API
export const ApartmentApi = {
  // 查询楼盘/公寓分页
  getApartmentPage: async (params: any) => {
    return await request.get({ url: `/business/apartment/page`, params })
  },

  // 查询楼盘/公寓详情
  getApartment: async (id: number) => {
    return await request.get({ url: `/business/apartment/get?id=` + id })
  },

  // 新增楼盘/公寓
  createApartment: async (data: ApartmentVO) => {
    return await request.post({ url: `/business/apartment/create`, data })
  },

  // 修改楼盘/公寓
  updateApartment: async (data: ApartmentVO) => {
    return await request.put({ url: `/business/apartment/update`, data })
  },

  // 修改楼盘/公寓
  updateApartmentStatus: async (data: ApartmentVO) => {
    return await request.put({ url: `/business/apartment/update/status`, data })
  },

  // 删除楼盘/公寓
  deleteApartment: async (id: number) => {
    return await request.delete({ url: `/business/apartment/delete?id=` + id })
  },

  // 导出楼盘/公寓 Excel
  exportApartment: async (params) => {
    return await request.download({ url: `/business/apartment/export-excel`, params })
  },

// ==================== 子表（楼盘/公寓户型） ====================

  // 获得楼盘/公寓户型分页
  getApartmentHouseTypePage: async (params) => {
    return await request.get({ url: `/business/apartment/apartment-house-type/page`, params })
  },
  // 新增楼盘/公寓户型
  createApartmentHouseType: async (data) => {
    return await request.post({ url: `/business/apartment/apartment-house-type/create`, data })
  },

  // 修改楼盘/公寓户型
  updateApartmentHouseType: async (data) => {
    return await request.put({ url: `/business/apartment/apartment-house-type/update`, data })
  },

  // 删除楼盘/公寓户型
  deleteApartmentHouseType: async (id: number) => {
    return await request.delete({ url: `/business/apartment/apartment-house-type/delete?id=` + id })
  },

  // 获得楼盘/公寓户型
  getApartmentHouseType: async (id: number) => {
    return await request.get({ url: `/business/apartment/apartment-house-type/get?id=` + id })
  },

// ==================== 子表（楼盘/公寓销售人员） ====================

  // 获得楼盘/公寓销售人员分页
  getApartmentSalespersonPage: async (params) => {
    return await request.get({ url: `/business/apartment/apartment-salesperson/page`, params })
  },
  // 新增楼盘/公寓销售人员
  createApartmentSalesperson: async (data) => {
    return await request.post({ url: `/business/apartment/apartment-salesperson/create`, data })
  },

  // 修改楼盘/公寓销售人员
  updateApartmentSalesperson: async (data) => {
    return await request.put({ url: `/business/apartment/apartment-salesperson/update`, data })
  },

  // 删除楼盘/公寓销售人员
  deleteApartmentSalesperson: async (id: number) => {
    return await request.delete({ url: `/business/apartment/apartment-salesperson/delete?id=` + id })
  },

  // 获得楼盘/公寓销售人员
  getApartmentSalesperson: async (id: number) => {
    return await request.get({ url: `/business/apartment/apartment-salesperson/get?id=` + id })
  },
}
